//
// Created by shrike on 16-9-21.
//

#ifndef BANKQUEUE_TEST_H
#define BANKQUEUE_TEST_H

#include <ctime>
#include <iostream>

#define USE_SELF_DEFINE_QUEUE 1 //use self define queue or STL
#if USE_SELF_DEFINE_QUEUE
#include "manager.h"
#else
#include "manager_queue.h"
#endif

class Test {
public:
  static void run(int total_serve_time, int service_num, int simulate_num);
  static void print_current_time();

};

void Test::print_current_time() {
  time_t t = time(0);
  char tmp[64];
  strftime(tmp, sizeof(tmp), "%Y/%m/%d %X", localtime(&t));
  std::cout << "current time: " << tmp << std::endl;
}

void Test::run(int total_serve_time, int service_num, int simulate_num) {
  std::srand(static_cast<unsigned  int>(std::time(0)));
  time_t start, end;

  time(&start);

  Manager manager(total_serve_time, service_num);
  manager.simulate(simulate_num);

  time(&end);

  std::cout << "The average time of customer stay in bank: "
    << manager.get_avg_stay_time() << std::endl;
  std::cout << "The number of customer be served per minute: "
    << manager.get_avg_customers() << std::endl;

  std::cout << "Simulate cost time: "
    << difftime(end, start) << " s " << std::endl;
}

#endif //BANKQUEUE_TEST_H